﻿<UserControl xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"  xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"             
    xmlns:viewmodels="clr-namespace:SuperLauncher.ViewModels"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"               
    x:Class="SuperLauncher.Views.JumpListItemInfoEditView"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400"             
    xmlns:sl8="http://www.sl8.so" >
    <UserControl.Resources>
        <sl8:EditStatusToEnabledConverter x:Key="editStatusToEnabledConverter"/>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" sl8:ChildWindowService.IsClose="{Binding Path=IsClose}" d:DataContext="{d:DesignInstance Type=viewmodels:JumpListItemInfoEditViewModel}" >
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Border Margin="8" x:Name="editPanel" sl8:ValidateService.ValidateCommand="{Binding Path=SaveCommand}">
                <StackPanel DataContext="{Binding JumpListItem}" >
                    <toolkit:DataField IsEnabled="{Binding Path=DataContext.EditStatus, Converter={StaticResource editStatusToEnabledConverter},ElementName=LayoutRoot}" >
                        <sdk:AutoCompleteBox Text="{Binding Mode=TwoWay, Path=CategoryTitle, ValidatesOnExceptions=True, NotifyOnValidationError=True}" ItemsSource="{Binding Path=CategoryInfos}"  DataContext="{Binding ElementName=LayoutRoot, Path=DataContext}" ValueMemberPath="Title" FilterMode="None">
                            <sdk:AutoCompleteBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Title}"/>
                                </DataTemplate>
                            </sdk:AutoCompleteBox.ItemTemplate>
                        </sdk:AutoCompleteBox>
                    </toolkit:DataField>
                    <toolkit:DataField>
                        <TextBox Text="{Binding Title, Mode=TwoWay}" />
                    </toolkit:DataField>
                    <toolkit:DataField>
                        <TextBox Text="{Binding Path, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}" />
                    </toolkit:DataField>
                    <toolkit:DataField>
                        <TextBox Text="{Binding CommandLineArguments, Mode=TwoWay}" />
                    </toolkit:DataField>
                    <toolkit:DataField>
                        <TextBox Text="{Binding StartDirectory, Mode=TwoWay}" />
                    </toolkit:DataField>
                    <toolkit:DataField>
                        <TextBox Text="{Binding Description, Mode=TwoWay}" />
                    </toolkit:DataField>
                </StackPanel>
            </Border>
            <StackPanel Orientation="Horizontal"  HorizontalAlignment="Center" Grid.Row="1" Margin="8">
                <Button Content="OK" Margin="12,0" >
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="Click">
                            <sl8:TriggerValidateAction TargetName="editPanel" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </Button>
                <Button Content="Cancel" Command="{Binding CancelCommand}" Margin="12,0" />
            </StackPanel>
        </Grid>
    </Grid>
</UserControl>
